import { location_href } from '../../../../../global/Func/location_href';
import { cur_event_check } from '../../../../global_comps/Classes/cla_event_check';
import { forBindEventThis } from '../../../../global_comps/Func/forBindEventThis';
import { user_sign_dataMana } from './cla_user_sign_dataMana';
import type { user_sign_props } from './cla_user_sign_props';

const user_sign_operateTag = 'user_sign_operate';

export class user_sign_operate extends user_sign_dataMana {
  get [Symbol.toStringTag]() {
    return user_sign_operateTag;
  }

  constructor(props: user_sign_props) {
    super(props);

    forBindEventThis(this);

    this.eventM.addEventListen(
      this.inp_identity,
      'blur',
      this.eventBind.inp_identity_blur
    );

    this.eventM.addEventListen(
      this.inp_name,
      'blur',
      this.eventBind.inp_name_blur
    );

    this.eventM.addEventListen(
      this.inp_phone,
      'blur',
      this.eventBind.inp_phone_blur
    );

    this.eventM.addEventListen(
      this.inp_passworld,
      'blur',
      this.eventBind.inp_passworld_blur
    );

    this.eventM.addEventListen(
      this.inp_passworld_certain,
      'blur',
      this.eventBind.inp_passworld_certain_blur
    );

    this.eventM.addEventListen(
      this.dom_submit,
      'click',
      this.eventBind.submit_click
    );

    this.eventM.addEventListen(
      this.dom_border,
      'click',
      this.eventBind.signed_login
    );

    this.freeze_border_click();
  }

  /**
   * 用户名 失焦 测定
   */
  inp_name_blur() {
    this.set_cur_dom_val(this.inp_name);
  }

  /**
   * 手机号 失焦 测定
   */
  inp_phone_blur() {
    this.set_cur_dom_val(this.inp_phone);
  }

  /**
   * 身份号 失焦 测定
   */
  inp_identity_blur() {
    this.set_cur_dom_val(this.inp_identity);
  }

  /**
   * 密码 失焦 测定
   */
  inp_passworld_blur() {
    this.set_cur_dom_val(this.inp_passworld);
  }

  /**
   * 密码 确认 失焦 测定
   */
  inp_passworld_certain_blur() {
    this.set_cur_dom_val(this.inp_passworld_certain);

    if (this.check_passworld_is_same()) {
      return;
    } else {
      this.passworld_is_not_same();
    }
  }

  /**
   * 提交 按钮 左键单击
   */
  submit_click(event: MouseEvent) {
    if (!cur_event_check.set_cur_event(event).left_click().result) {
      return;
    }

    this.submit_info();
  }

  /**
   * 用户 登录
   */
  signed_login() {
    this.set_localstorage_cur_user_identity();

    location_href('');
  }
}
